/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controllers;

import DAO.EventDAO;
import java.io.IOException;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import model.EventBean;
import model.UserBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 *
 * @author emovabilisim
 */

@Controller
public class CreateEventResultController {
    @RequestMapping("createeventresult.htm")
    public void createContrwads(Map model,HttpServletRequest request,HttpServletResponse response, EventBean eventBean){
        
        HttpSession session = request.getSession(true);
        UserBean userBean = (UserBean)(session.getAttribute("currentSessionUser"));
        
        EventDAO eventDAO = new EventDAO();
        eventDAO.insertEvent(eventBean,userBean);
        
        System.out.println(eventBean.getName() + "is written to DB") ;
        try {
            response.sendRedirect("willingwalkerevents.htm");
        } catch (IOException ex) {
            Logger.getLogger(CreateEventResultController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
